import { configureStore, ThunkAction, Action } from "@reduxjs/toolkit";
import AuthReducer from "./Auth";
import RouterReducer from './Router';
import PersonalInformationReducer from './PersonalInformation';
import UserManagementReducer from "./UserManagement";
import SupplierManagementReducer from "./SupplierManagement";
import CommodityManagementReducer from "./CommodityManagement";
import WarehouseManagementReducer from "./WarehouseManagement";
import GlobalAlertReducer from "./GlobalAlert";
import InventoryManagementReducer from "./InventoryManagement";

export const store = configureStore({
  reducer: {
    authReducer: AuthReducer,
    routerReducer: RouterReducer,
    profileReducer: PersonalInformationReducer,
    userManagementReducer: UserManagementReducer,
    supplierManagementReducer: SupplierManagementReducer,
    commodityManagementReducer: CommodityManagementReducer,
    warehouseManagementReducer: WarehouseManagementReducer,
    inventoryManagementReducer: InventoryManagementReducer,
    globalAlertReducer: GlobalAlertReducer
  }
});

export type AppDispatch = typeof store.dispatch;
export type RootState = ReturnType<typeof store.getState>;
export type AppThunk<ReturnType = void> = ThunkAction<
  ReturnType,
  RootState,
  unknown,
  Action<string>
>;
